import { CurrentUser } from './current-user.decorator'
import { Controller, Get, Post, Body, UseGuards } from '@nestjs/common'
import { AuthService } from './auth.service'
import { RegisterDto } from './dto/register.dto'
import { LoginDto } from './dto/login.dto'
import { Auth } from './auth.decorator'
import { User } from '@prisma/client'

@Controller('auth')
export class AuthController {
	constructor(private readonly auth: AuthService) {}

	@Post('register')
	register(@Body() dto: RegisterDto) {
		return this.auth.register(dto)
	}

	@Post('login')
	login(@Body() dto: LoginDto) {
		return this.auth.login(dto)
	}

	@Get('test')
	@Auth()
	test(@CurrentUser() user: User) {
		return user
	}
}
